class Bot extends Player {
    private static final int NUM_OF_RANKS = 13;
    private static final int PAIR_RANK = 1;
    private static final int TWO_PAIR_RANK = 2;
    private static final int THREE_RANK = 3;
    private static final int STRAIGHT_RANK = 4;
    private static final int STRAIGHT_FLUSH_RANK = 8;
    private static final int JACK_RANK = 9;
    private static final int HAND_SIZE = 5;
	Bot(int startamount) {
		super(startamount);
	}

	@Override
	public int[] picks() {
	    int myrank = evaluateHand();
	    int[] myranks = getHand().getRanks();
	    int[] result;
	    int amount = 0;
	    if (myrank <= STRAIGHT_FLUSH_RANK && myrank >= STRAIGHT_RANK) {
	        amount = 0;
	        result = new int[amount];
	    } else if (myrank == THREE_RANK || myrank == PAIR_RANK) {
	        for (int i = 0; i < NUM_OF_RANKS; i++) {
	            if (myranks[i] == 1 && i < JACK_RANK) {
	                amount++;
	            }
	        }
	        result = new int[amount];
	        for (int i = 0; i < NUM_OF_RANKS; i++) {
                if (myranks[i] == 1 && i < JACK_RANK) {
                    result[amount - 1] = getHand().findRankIndex(i);
                    amount--;
                }
                if (amount == 0) {
                    break;
                }
            }
	        for (int i = 0; i < amount; i++) {
	            for (int j = 0; j < NUM_OF_RANKS; j++) {
	                if (myranks[j] == 1 && j < JACK_RANK) {
	                    result[i] = getHand().findRankIndex(j);
	                }
	            }
	        }            
	    } else if (myrank == TWO_PAIR_RANK) {
	        amount = 1;
	        result = new int[amount];
	        for (int i = 0; i < NUM_OF_RANKS; i++) {
	            if (myranks[i] == 1) {
	                result[amount - 1] = getHand().findRankIndex(i);
	            }
	        }
	    } else {
	        amount = 4;
	        result = new int[amount];
	        for (int i = 0; i < NUM_OF_RANKS; i++) {
	            if (myranks[i] == 1) {
	                result[HAND_SIZE - 1 - amount] = getHand().findRankIndex(i);
	                amount--;
	                if (amount == 0) {
	                    break;
	                }
	            }
	        }
	    }
		return result;
	}
	
	public int getDecision(int maxbet, boolean allIn) throws PokerException {
	    int myrank = evaluateHand();
	    int bet;
	    if (allIn) {
	        if (myrank >= STRAIGHT_RANK) {
	     //       bet();
	            bet = getCash();
	        }
	        else {
	            fold();
	            bet = -1;
	        }
	    }
	    else {
    	    if (myrank >= STRAIGHT_RANK) {                 // all in
    	 //       bet();
    	        bet = getCash();
    	    }
    	    else if (myrank == THREE_RANK) {               // bet/raise
    	//       bet();
    	        bet = (maxbet - myBet()) + getCash()/2;
    	    }
    	    else if (myrank == TWO_PAIR_RANK) {        // bet/raise
    	//        bet();
    	        bet = (maxbet - myBet()) + getCash()/3;
    	    }
    	    else if (myrank == PAIR_RANK) {            // check/call
      //          check();
                bet = maxbet - myBet();
            }
    	    else {                                 // check/fold
    	        if (maxbet == myBet()) {
    	//            check();
    	            bet = 0;
    	        }
    	        else {
    	            fold();
    	            bet = -1;
    	        }
    	    }
	    }
	    if (bet >= getCash()) {
	        bet = getCash();
	    }
	    else if (bet >= 0) {
	        addToMyBet(bet);
	        addToCash(-bet);
	    }
	    return bet;
	}
}
